
import java.util.ArrayList;

public class BubbleSort {
	/**
	 * BubbleSort 
	 * Algorithm 
	 * 1. Compare each pair of adjacent elements from the beginning 
	 * of an array and, if they are in reversed order, swap them. 
	 * 2. If at least one swap has been done, repeat step 1.
	 */
	public static ArrayList<String> bubbleSort(ArrayList<String> arr) {

		boolean swapped = true;
		int j = 0;
		String tmp;

		while (swapped) {
			swapped = false;
			j++;
			for (int i = 0; i < arr.size() - j; i++) {
				if (Double.parseDouble(arr.get(i)) > Double.parseDouble(arr.get(i + 1))) {
					tmp = arr.get(i);
					arr.set(i, arr.get(i + 1));
					arr.set(i + 1, tmp);
					swapped = true;
				}
			}
		}
		return arr;
	}

}
